@/*
select标签中各个参数的说明:
name : select的名称
id : select的id
hasEmpty:false
code : 字典的code
map : 选项map 示例：{'1':'目录','2':'菜单','3':'权限'};
url: 动态选项地址
key: 动态key
text: 动态text
pid: 父级下拉框id
@*/
@if(isNotEmpty(widgetParam)){
@var _wpMap = {};
@var _tmpLs = strutil.split(widgetParam,",");
@for(ele in _tmpLs){
@var _ele = strutil.split(ele,"=");
@_wpMap[_ele[0]]=_ele[1];
@}
@code = _wpMap["code"];
@url = _wpMap["url"];
@key = _wpMap["key"];
@text = _wpMap["text"];
@pid = _wpMap["pid"];
@hasEmpty = _wpMap["hasEmpty"];
@}
@hasEmpty = isEmpty(hasEmpty)?'true':hasEmpty;
@hasEmpty = hasEmpty=='true'?true:false;

<div class="form-group">
    @if(!isEmpty(name)){
    <label for="${id}" class="control-label">${name}</label>
    @}
    <select class="hisui-combobox" id="${id}" name="${id}"
            @if(isEmpty(width)){
            @	width="160px";
            @}
            style="width:${width!}">
    </select>
</div>
@if(isNotEmpty(key) && isNotEmpty(text)){
<script>
    /**
     *url 请求地址
     *params 请求参数
     *defVal 默认值
     *hasNone 是否有空项
     */
    var ${id}_loadOptions=function(url,params,defVal,hasNone){
        //$("#${id}").html(hasNone?"<option value=''></option>":"");
        $.ajax({
            url : url,
            async : false,
            cache : false,
            data : params?params:{},
            success : function(data) {
                $("#${id}").combobox({
                    data: data,
                    valueField: '${key}',
                    textField: '${text}',
                    onLoadSuccess:function () {
                        $(this).combobox("select", defVal);
                    }
                });
            }
        })
    }
    var ${id}_defVal = "";
    @if(isNotEmpty(value)){
        ${id}_defVal = "${value}";
    @}
    //$(document).ready(function(){
    @if((isNotEmpty(url)&&isEmpty(pid)&&isEmpty(value))||(isNotEmpty(url)&&isNotEmpty(value))){
        var _params = null;
    @if(isNotEmpty(pid)){
            _params = {"${pid}": ${pid}_defVal};
        @}
        ${id}_loadOptions("${url}",_params,'${value!}',true);
    @}
    @if(isNotEmpty(pid)){
        $('#${pid}').combobox({
            onChange: function () {
                if($("#${pid}").combobox("getValue")!=""){
                    ${id}_loadOptions("${url}"+"/"+$("#${pid}").combobox("getValue"),{"${pid}":$("#${pid}").combobox("getValue")},null,true);
                }
            }
        });
    @}
    //})
</script>
@}
